(function($) {
    $.commonSearch=function(){
        var $commonSearch={};
		var cGlobal={};
        $commonSearch.methods={
            init:function(){
               	new $.search(".searchinput_redesignWrapper",{
               	    list:".headSeachList",listType:"li",
               	    //键入的事件
               	    keyEnter:function(str,dom){},
					
               	    //请求ajax之前
               	    ajaxStart:function(){
						var that=this;
						clearTimeout(cGlobal.searchSuggestionDelay);
						cGlobal.searchSuggestionDelay=setTimeout(function(){
							that.ajax($common.dev.getAjaxUrl("search"))
						},1800);
					},
               	    //ajax完成之后
               	    addData:function(data){
						if(data.product.length==0)return;
               	    	var html = '<div class="column search_proType">\
                            	<div class="headline">相关关键字</div>\
                                <div class="headProTit Keywordlist">\
                                </div>\
                            </div>\
                            <div class="column headProducts">\
                            	<div class="headline">产品</div>\
                                 <div class="suggestList productslist">\
                                </div>\
                            </div>\
                            <div class="column headProducts ">\
                            	<div class="headline"></div>\
                                <div class="headProTit typelist">\
                                 </div>\
                        </div>'
                        $('.headSeachList').append(html)
						
						$.each(data.info,function(index,item){
								 if(item.name!=""){
									$('.headSeachList .Keywordlist').append('<a href="'+item.url+'" title="men">'+item.name+'</a>')
								}else{
									 $(".headSeachList").addClass("headNoSeachList");
									 $(".column.search_proType").hide();
								}
						 });
               	    	 $.each(data.product,function(index,item){
							var _tempHtml;
							 if(item.numb==0){
                                                                var itemUrl="'"+item.url+"'";  
                                                                var itemName="'"+item.name+"'"; 
                                                                var search_term="'"+$("#arvato_q").val()+"'";
								 _tempHtml=$('<div class="headSearchBox cf"><a onclick="utag_addto_search_term('+itemUrl+','+itemName+','+search_term+')"  title="" class="headProImg"><img src="'+item.img+'" alt="" /></a><div class="headProTxt"><a href="'+item.url+'" onclick="utag_addto_search_term('+itemUrl+','+itemName+','+search_term+')"><i class="textProName">'+item.name+'</i><br /><i>'+item.stitle+'</i></a><span class="mini_price">¥'+item.price+'</span></div></div>');
								$('.headSeachList .productslist').append(_tempHtml);
							 }else{
								 var _starts="";
								for(var q=0; q<5; q++){
									if(q<item.starts){
										_starts=_starts+'<li class="empty filled"></li>';
									}else{
										_starts=_starts+'<li class="empty"></li>';
									}
								};
                                                                var itemUrl="'"+item.url+"'";  
                                                                var itemName="'"+item.name+"'"; 
                                                                var search_term="'"+$("#arvato_q").val()+"'";
                                                           
								_tempHtml=$('<div class="headSearchBox cf"><a onclick="utag_addto_search_term('+itemUrl+','+itemName+','+search_term+')"  title="" class="headProImg"><img src="'+item.img+'" alt="" /></a><div class="headProTxt"><a href="'+item.url+'" onclick="utag_addto_search_term('+itemUrl+','+itemName+','+search_term+')"><i class="textProName">'+item.name+'</i><br /><i>'+item.stitle+'</i></a><span class="mini_price">¥'+item.price+'</span><div class="ratingContainer"><ul class="ratingStars">'+_starts+'</ul><span class="ratingCount">共'+item.numb+'条评论</span></div></div></div>');
								$('.headSeachList .productslist').append(_tempHtml);
							 }
               	    	 });
						 
               	    	  //$.each(data.type,function(index,item){
               	    	// 	$('.headSeachList .typelist').append('<a href="#" title="men">'+item.name+'</a>')

               	    	 //});
               	    }
               	});
            }
        };
        return $commonSearch.methods;
    };
})(jQuery);